#define _CRT_SECURE_NO_WARNINGS

//202.快乐数

lass Solution {
public:
    int BitSum(int n)
    {
        int sum = 0;
        while(n)
        {
            int t = n % 10;
            sum += t * t;
            n /= 10;
        }
        return sum;
    }
    bool isHappy(int n) {
        int slow = n, fast = BitSum(n);
        while(slow != fast)
        {
            slow = BitSum(slow);
            fast = BitSum(BitSum(fast));
        }
        //查看相遇点是否是1
        return slow == 1;
    }
};
